﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Rapattern.Utilities
{
    public class Win32APIHelper
    {
        [DllImport("wininet.dll")]
        private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
        /// <summary>
        /// 检查网络连接状态，是否可以联网
        /// </summary>
        /// <returns></returns>
        public static bool IsInternetConnected()
        {
            int dwFlag = 0;
            bool state = InternetGetConnectedState(out dwFlag, 0);
            return state;
        }
    }
}
